/*
 * Copyright (c) 2014, S.F. Express Inc. All rights reserved.
 */
package org.jasig.cas.client.ext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jasig.cas.client.validation.Assertion;

/**
 * 描述：CAS客户端应用接口
 * 
 * <pre>
 * HISTORY
 * ****************************************************************************
 *  ID   DATE            PERSON          REASON
 *  1    2015年12月15日     014767          Create
 * ****************************************************************************
 * </pre>
 * 
 * @author 014767
 * @since 1.0
 */
public interface ICASClient {

    /**
     * 是否使用Session
     * 
     * @return
     */
    boolean useSession();

    /**
     * 判断请求是否登录
     * 
     * @param request
     * @param response
     * @return
     */
    boolean isLogin(final HttpServletRequest request, final HttpServletResponse response);

    /**
     * 登录成功回调
     * 
     * @param request
     * @param response
     * @param assertion
     *            用户信息
     * @return 如果本地验证成功，返回true，否则，返回false
     */
    boolean onLogin(final HttpServletRequest request, final HttpServletResponse response, final Assertion assertion) throws UserNotFoundError;

    /**
     * ST验证失败回调
     * 
     * @param request
     * @param response
     * @return 如果应用处理了失败过程，返回true; 如果应用不处理验证失败，返回false，此时cas会返回拒绝访问
     */
    boolean onFailedValidation(final HttpServletRequest request, final HttpServletResponse response);

    /**
     * 返回当前节点的IP、端口
     * 
     * @return
     */
    Node getNode();

}
